using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAO;

namespace ESWebFramework.I18N
{
    [DefaultProperty("TextReference")]
    [ToolboxData("<{0}:ESi18nRequiredFieldValidator runat=server></{0}:ESi18nRequiredFieldValidator>")]

    public class ESi18nRequiredFieldValidator : RequiredFieldValidator
    {
        
        public string TextReference
        {
            get
            {
                String s = (String)ViewState["TextReference"];
                return ((s == null) ? String.Empty : s);
            }

            set
            {
                ViewState["TextReference"] = value;
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            ESWebUserControl father = ESWebUserControl.checkParentType(this);
            if (father == null)
                throw (new Exception("Wrong type of Parent! The Parent control can not be casted correctly. " +
                        "The controls from the ESWebFramework library needs to be placed on a user" +
                        " control which inherits from ESWebUserControl."));

            if (TextReference != "" || TextReference != null)
                ErrorMessage = TextBaseFactory.loadText(TextReference, father.LangId);

        }
    }
}

